package com.part2.business.function.Impl;

import java.util.List;

import com.part2.action.common.validator.Validator;
import com.part2.beans.Job;
import com.part2.common.query.Page;
import com.part2.dao.common.BaseDao;
import com.part2.dao.function.JobDao;

public class JobServiceImpl implements com.part2.business.function.JobService {
	
	private BaseDao<Job,String> baseDao;
	private JobDao jobDao;
	
	
	public void setBaseDao(BaseDao<Job, String> baseDao) {
		this.baseDao = baseDao;
	}

	public void setJobDao(JobDao jobDao) {
		this.jobDao = jobDao;
	}

	public void addJob(Job job) {
		// TODO Auto-generated method stub
		baseDao.save(job);
	}

	public void deleteJob(String id) {
		// TODO Auto-generated method stub
		if(Validator.isNotNull(id)){
			Job jb = this.findJobByPrimeKey(id);
			if(jb!=null)
				baseDao.delete(jb);
		}
	}

	public List<Job> findJob() {
		// TODO Auto-generated method stub
		return baseDao.findAll(Job.class);
	}

	public Page<Job> findJob(Page<Job> page) {
		// TODO Auto-generated method stub
		return jobDao.findJob(page);
	}

	public Job findJobByPrimeKey(String id) {
		// TODO Auto-generated method stub
		return jobDao.findJobByPrimeKey(id);
	}

	public void updateJob(Job job) {
		// TODO Auto-generated method stub
		baseDao.saveOrUpdate(job);
	}

}
